package com.xbongbong.admin.model.impl;

import com.xbongbong.admin.domain.dao.MirrorBusinessRuleInfoDao;
import com.xbongbong.admin.domain.entity.MirrorBusinessRuleInfoEntity;
import com.xbongbong.admin.model.MirrorBusinessRuleInfoModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 业务规则-镜像
 * @author xingxing.xiao
 * @date 2020/06/11 16:58
 */
@Service("mirrorBusinessRuleInfoModel")
public class MirrorBusinessRuleInfoModelImpl implements MirrorBusinessRuleInfoModel {

    @Resource
    private MirrorBusinessRuleInfoDao mirrorBusinessRuleInfoDao;

    @Override
    public Integer insert(MirrorBusinessRuleInfoEntity entity) {
        long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return mirrorBusinessRuleInfoDao.insert(entity);
    }

    @Override
    public Integer update(MirrorBusinessRuleInfoEntity entity) throws XbbException {
        long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return mirrorBusinessRuleInfoDao.update(entity);
    }

    @Override
    public List<MirrorBusinessRuleInfoEntity> findEntitys(Map<String, Object> param) {
        return mirrorBusinessRuleInfoDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return mirrorBusinessRuleInfoDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer delete(Long key, String corpid) {
        return mirrorBusinessRuleInfoDao.deleteByKey(key, corpid);
    }

    @Override
    public List<MirrorBusinessRuleInfoEntity> getByFormId(Long formId, Integer businessType, Long mirrorId) {
        return mirrorBusinessRuleInfoDao.getByFormId(formId, businessType, mirrorId);
    }

    @Override
    public List<MirrorBusinessRuleInfoEntity> insertBatch(List<MirrorBusinessRuleInfoEntity> list) {
        mirrorBusinessRuleInfoDao.insertBatch(list);
        return list;
    }
}
